package J20250330_real;

/**
 * Created with IntelliJ IDEA.
 * Description: 拉马车——https://www.lanqiao.cn/problems/101/learning/?page=1&first_category_id=1&difficulty=20&second_category_id=3
 * User: 王圆豪
 * Date: 2025-04-09
 * Time: 20:27
 */
import java.util.*;
//1:无需package
//2: 类名必须Main, 不可修改

public class Main13 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        Queue<Character> a = new LinkedList<>();
        Queue<Character> b = new LinkedList<>();
        String s1 = scan.next();
        String s2 = scan.next();
        for(char tmp : s1.toCharArray()) a.add(tmp);
        for(char tmp : s2.toCharArray()) b.add(tmp);
        Stack<Character> table = new Stack<>();
        int m = 0;
        HashSet<Character> set = new HashSet<>();
        char ch = '0';
        while(!a.isEmpty() && !b.isEmpty()){
            if(m == 0 || m == -1) {
                ch = a.poll();
                if(set.contains(ch)) {
                    a.add(ch);
                    while(!table.isEmpty()&&table.peek()!=ch) {
                        char kk = table.pop();
                        a.add(kk);
                        set.remove(kk);
                    }
                    if(!table.isEmpty()) a.add(table.pop());
                    set.remove(ch);
                    m = -1;
                }else {
                    m = 0;
                    set.add(ch);
                    table.add(ch);
                }
            }
            if(a.isEmpty())break;
            if(m == 0 || m == 1) {
                ch = b.poll();
                if(set.contains(ch)) {
                    b.add(ch);
                    while(!table.isEmpty()&&table.peek()!=ch) {
                        char kk = table.pop();
                        b.add(kk);
                        set.remove(kk);
                    }
                    if(!table.isEmpty()) b.add(table.pop());
                    set.remove(ch);
                    m = 1;
                }else {
                    m = 0;
                    set.add(ch);
                    table.add(ch);
                }
            }
        }
        Queue<Character> cur = a.isEmpty() ? b : a;
        while(!cur.isEmpty()){
            System.out.print(cur.poll());
        }
        scan.close();
    }
}